<?php

namespace privateClass\App;

class Application {
	function __construct() {
		
	}
	
	function __destruct() {
		
	}

	/**
	 * 获取配置文件信息
	 * @param string $app_code
	 * @param string $_get_all_status
	 * @return Ambigous <boolean, \privateClass\App\Ambigous, \privateClass\App\multitype:, multitype:, unknown>
	 */
	public function get_config($app_code = NULL, $_query_string, $_is_static = FALSE, $_get_all_status = FALSE) {
		$result = FALSE;
		$app_code == NULL ? $app_code = '' : FALSE;
		$sql = 'SELECT `app_code`, `APP_ID` as `app_id`, `status` FROM '.DB__MOBILE_OPEN_PLATFORM__APP_CONFIGS.'
				WHERE `app_code` = \''.$app_code.'\' ';
		$_get_all_status == FALSE ? $sql .= ' AND `enabled` = 1' : FALSE;
		$retval = \privateClass\Kernel\MYSQL::query($sql,_MYSQL_QUERY);
		if (isset($retval[0])) {
			$tmp = $retval[0];
			//初始化config.ini路径
			$tmp['config_path'] = _PROJECT_TEMPLATE_ROOT.DIRECTORY_SEPARATOR.$tmp['app_id'].DIRECTORY_SEPARATOR.PROJECT_CONFIG_PATH.DIRECTORY_SEPARATOR.'config.ini';
			//初始化模板路径
			$tmp['template_path'] = _PROJECT_TEMPLATE_ROOT.DIRECTORY_SEPARATOR.$tmp['app_id'].DIRECTORY_SEPARATOR.PROJECT_WWW_PATH.DIRECTORY_SEPARATOR;
			//初始化缓存文件路径
			$tmp['cache_path'] = _PROJECT_TEMPLATE_ROOT.DIRECTORY_SEPARATOR.$tmp['app_id'].DIRECTORY_SEPARATOR.PROJECT_CACHE_PATH.DIRECTORY_SEPARATOR;
			//读取conf配置文件
			$result = \privateClass\App\Config::get($_query_string, $tmp, $_is_static);
		}
		return $result;
	}
	
	/**
	 * 转换query_string格式为可读取的格式
	 * @param string $_request_method
	 * @return Ambigous <boolean, string>
	 */
	public function parse_query_string($_request_method = NULL) {
		return \privateClass\App\Query::parse($_request_method);
	}
	
	/**
	 * 
	 * @param unknown $_query_string
	 * @param unknown $_conf
	 * @return Ambigous <\privateClass\App\mixed, multitype:>
	 */
	public function fetch($_query_string, $_conf) {
		return \privateClass\App\Data::fetch($_query_string, $_conf);
	}
	
	/**
	 * 
	 * @param unknown $_contents
	 * @param unknown $_conf
	 * @return Ambigous <\privateClass\App\mixed, multitype:string >
	 */
	public function get_stream($_contents, $_conf) {
		return \privateClass\App\Data::get_stream($_contents, $_conf);
	}
	
	/**
	 * 
	 * @param unknown $_contents
	 * @param unknown $_conf
	 * @return Ambigous <\privateClass\App\mixed, boolean, multitype:NULL , NULL, multitype:array multitype:array NULL  NULL , multitype:array NULL >
	 */
	public function get_vars($_contents, $_conf, $charset = 'utf-8') {
		return \privateClass\App\Data::get_vars($_contents, $_conf, $charset);
	}
}

?>